package com.eeboot.vo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegTest {
    public static String getMatcher(String regex, String source) {
                 String result = "";
                Pattern pattern = Pattern.compile(regex);
                 Matcher matcher = pattern.matcher(source);
                 while (matcher.find()) {
                     System.out.println(matcher.groupCount());
                     for(int i=0;i<=matcher.groupCount();i++){
                         System.out.println(matcher.group(i));
                     }
                 }
                 return result;
             }

             public static void main(String[] args) {
                 String url = "[bsd-portal] [test] [localhost.localdomain] [172.19.80.101] 2019-04-24 10:49:55.594 [redisMessageListenerContainer-74706] [TID: N/A] [SPID:N/A] INFO  com.bsmartd.handler.SessionAccessListener - 当前用户13510593882登录状态超时";
                 String regex = "\\[([^]]*)]\\s+\\[([^]]*)]\\s+\\[([^]]*)]\\s+\\[([^]]*)]\\s+(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\.\\d{3})\\s+\\[([^]]*)]\\s+\\[([^]]*)]\\s+\\[([^]]*)]\\s+(\\w{3,5})\\s+(.*)";
                 getMatcher(regex,url);
             }
}
